package com.gonsin.gview.model.dynamic.data;

import com.gonsin.gview.annotations.impl.EmptyListDataPicker;
import com.gonsin.gview.annotations.interfaces.IListDataPicker;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * item为基本数据类型的列表
 */
@Data
public class DynamicSimpleListData {

    /**
     * 直接输入sql语句查询数据（如果查询到多个，则会返回第一个）
     */
    private String fromSql = "";
    public static DynamicSimpleListData fromSql(String fromSql){
        DynamicSimpleListData data = new DynamicSimpleListData();
        data.fromSql = fromSql;
        return data;
    }

    /**
     * 通过dataPicker写java语句查询数据（此方法最为灵活）
     */
    private IListDataPicker fromListDataPicker;
    public static DynamicSimpleListData fromListDataPicker(IListDataPicker fromListDataPicker){
        DynamicSimpleListData data = new DynamicSimpleListData();
        data.fromListDataPicker = fromListDataPicker;
        return data;
    }

    /**
     * 通过dataPicker写java语句查询数据（此方法最为灵活）
     */
    private String fromListDataPickerClassName = "";
    public static DynamicSimpleListData fromListDataPickerClassName(String fromListDataPickerClassName){
        DynamicSimpleListData data = new DynamicSimpleListData();
        data.fromListDataPickerClassName = fromListDataPickerClassName;
        return data;
    }

    /**
     * 通过静态json返回，适合静态数据
     */
    private String fromJson = "";
    public static DynamicSimpleListData fromJson(String fromJson){
        DynamicSimpleListData data = new DynamicSimpleListData();
        data.fromJson = fromJson;
        return data;
    }

    /**
     * 通过@GDataSource获取数据
     */
    private String fromDataSource = "";
    public static DynamicSimpleListData fromDataSource(String fromDataSource){
        DynamicSimpleListData data = new DynamicSimpleListData();
        data.fromDataSource = fromDataSource;
        return data;
    }

}
